Skip to content

mi: Additional define options for older systems with SIOCMCTPALLOC#1019

Merged
igaw merged 1 commit intolinux-nvme:masterfrom
chorkin:user/chorkin/defines
Jun 27, 2025
Merged

mi: Additional define options for older systems with SIOCMCTPALLOC#1019
igaw merged 1 commit intolinux-nvme:masterfrom
chorkin:user/chorkin/defines

Conversation

@chorkin
Copy link
Copy Markdown
Contributor

@chorkin chorkin commented May 30, 2025

Older systems (WSL for example) may not include SIOCMCTPALLOC defines and structs and when enabling in MCTP code will cause build errors. This is a workaround.

@chorkin
Copy link
Copy Markdown
Contributor Author

chorkin commented May 30, 2025

@jk-ozlabs , I'd love your feedback here. I stumbled across an issue in my build environment where I do have the Mctp.h header, but it doesn't include these defines or structures. However, my target environment will support these, so I need to build for that. I also didn't want to force these IOCTLs to be activated if a system didn't support it, so I've added a USE_SIOCMCTPALLOC define to activate it in this case.

@jk-ozlabs
Copy link
Copy Markdown
Collaborator

Makes sense - there are some considerations about which definitions may be available at which points in the kernel releases, so I'll need to have a more thorough look through those. I'll get a review done shortly.

@chorkin
Copy link
Copy Markdown
Contributor Author

chorkin commented Jun 12, 2025

@jk-ozlabs any new thoughts on this?

Copy link
Copy Markdown
Collaborator

@jk-ozlabs jk-ozlabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay - managed to get the kernel archaeology done for the timing of the uapi changes. A couple of comments inline.

Comment thread src/nvme/mi-mctp.c Outdated

#endif /* !AF_MCTP */

#if !defined(MCTP_TAG_PREALLOC) && defined(USE_SIOCMCTPALLOC)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MCTP_TAG_PREALLOC hit the uapi at the same time as the tag control ioctls (SIOCMCTPALLOCTAG and SIOCMCTPDROPTAG), so keying off that makes sense.

however, USE_SIOMCTPALLOC doesn't appear anywhere else, so I'm not sure what your intention there is?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intention was we don't want ALL builds to include this on a system that doesn't have these headers. Because maybe the dev is going to run it on the same system without this support. So I added this extra new define for them to use to enable this feature.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because maybe the dev is going to run it on the same system without this support

but we should already handle that case at runtime:

libnvme/src/nvme/mi-mctp.c

Lines 194 to 202 in 80763da

rc = ops.ioctl_tag(mctp->sd, SIOCMCTPALLOCTAG, &ctl);
if (rc) {
if (!logged) {
/* not necessarily fatal, just means we can't handle
* "more processing required" messages */
nvme_msg(ep->root, LOG_INFO,
"System does not support explicit tag allocation\n");
logged = true;
}

.. or are you after different behaviour here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh!. I didn't realize this was how it works. Knowing this, I'll remove my extra define as it doesn't really make much sense.

Comment thread src/nvme/mi-mctp.c Outdated
Comment thread src/nvme/mi-mctp.c Outdated
@chorkin chorkin force-pushed the user/chorkin/defines branch from 4e69b48 to 80763da Compare June 13, 2025 16:46
@jk-ozlabs
Copy link
Copy Markdown
Collaborator

Just to clarify this: the USE_SIOCMCTPALLOC introduces an (undocumented) build configuration of libnvme, which has the potential to double the test requirements on this code, and a somewhat obscure requirement to set the define.

The use-case for this would be: "set USE_SIOMCTPALLOC if would like to disable the ioctls for libnvme runtime (but we would advise against this), but only if your build environment does not provide the ioctl definitions, in which case the value is ignored.". That's a pretty awkward user-experience for the library.

I'm definitely up for introducing the backwards-compat definitions, to allow the build environment to be unified. However, if we're taking this approach, we should then always attempt the ioctls (ie, remove the later #ifdef SIOCMCTP*s, and have graceful failure case if they are not available.

If the current failure code isn't appropriate for your usage, let me know. However, I think a one-time warning is justified, as that means the MPR responses will not work.

@chorkin chorkin force-pushed the user/chorkin/defines branch from 80763da to 3856fb7 Compare June 16, 2025 23:30
@jk-ozlabs
Copy link
Copy Markdown
Collaborator

OK, looks better, but now that SIOMCTPALLOC is always defined, you'll want to remove the #else case later in the file (line 225) that allows for the not-defined scenario.

Older systems (WSL for example) may not include SIOCMCTPALLOC defines
and structs and when enabling in MCTP code will cause build errors.
This is a workaround.

Signed-off-by: Chuck Horkin <[email protected]>
@chorkin chorkin force-pushed the user/chorkin/defines branch from 3856fb7 to b750907 Compare June 17, 2025 15:54
Copy link
Copy Markdown
Collaborator

@jk-ozlabs jk-ozlabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@chorkin
Copy link
Copy Markdown
Contributor Author

chorkin commented Jun 23, 2025

@igaw can we merge this?

@igaw igaw merged commit b07041b into linux-nvme:master Jun 27, 2025
12 checks passed
@igaw
Copy link
Copy Markdown
Collaborator

igaw commented Jun 27, 2025

Sorry for the delay, as usual trying to do too many things at the same time.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants